package com.sky.controller.user;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.CacheNamespace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userSetMealController")
@RequestMapping("/user/setmeal")
@Api(tags = "套餐管理相关接口")
@Slf4j
public class SetMealController {

    @Autowired
    private SetmealService setmealService;

    @GetMapping("/list")
    @ApiOperation("根据分类id查询套餐")
    @Cacheable(cacheNames="setmealCache", key="#categoryId")
    public Result<List<Setmeal>> list(@RequestParam Long categoryId){
        return Result.success(setmealService.list(categoryId));
    }

    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id查询套餐下的菜品")
    public Result<List<DishItemVO>> getDishesBySetmealId(@PathVariable Long id){
        return Result.success(setmealService.getDishesBySetmealId(id));
    }
}
